#include <iostream>
#include <GL/glut.h>
#include <math.h>
#include <stdio.h>
#include "DefaultCube.h"

//-----------------------------------------------------------------
//  DefaultCube class
//-----------------------------------------------------------------


// vertices (static)
GLfloat DefaultCube::A[] = { 0.0f, 1.0f, 1.0f }; 
GLfloat DefaultCube::B[] = { 1.0f, 1.0f, 1.0f }; 
GLfloat DefaultCube::C[] = { 1.0f, 1.0f, 0.0f }; 
GLfloat DefaultCube::D[] = { 0.0f, 1.0f, 0.0f }; 
GLfloat DefaultCube::E[] = { 0.0f, 0.0f, 1.0f }; 
GLfloat DefaultCube::F[] = { 1.0f, 0.0f, 1.0f }; 
GLfloat DefaultCube::G[] = { 1.0f, 0.0f, 0.0f }; 
GLfloat DefaultCube::H[] = { 0.0f, 0.0f, 0.0f }; 

// texture coordinates (static)
GLfloat DefaultCube::bottomLeft[] = {0.0f, 0.0f};
GLfloat DefaultCube::bottomRight[] = {1.0f, 0.0f};
GLfloat DefaultCube::topLeft[] = {0.0f, 1.0f};
GLfloat DefaultCube::topRight[] = {1.0f, 1.0f};


DefaultCube::DefaultCube(void)  {
}

void DefaultCube::display(void) {

	glTranslatef(-0.5, -0.5, -0.5);  // move to origin

	// top
	glBegin(GL_QUADS);
		glNormal3f( 0.0, 1.0, 0.0);
		glTexCoord2fv(bottomLeft);
		glVertex3fv(A);
		glTexCoord2fv(bottomRight);
		glVertex3fv(B);
		glTexCoord2fv(topRight);
		glVertex3fv(C);
		glTexCoord2fv(topLeft);
		glVertex3fv(D);
	glEnd();
	
	// bottom
	glBegin(GL_QUADS);
		glNormal3f( 0.0, -1.0, 0.0);
		glTexCoord2fv(bottomLeft);
		glVertex3fv(H);
		glTexCoord2fv(bottomRight);
		glVertex3fv(G);
		glTexCoord2fv(topRight);
		glVertex3fv(F);
		glTexCoord2fv(topLeft);
		glVertex3fv(E);
	glEnd();
	
	// Front
	glBegin(GL_QUADS);
		glNormal3f( 0.0, 0.0, 1.0);
		glTexCoord2fv(bottomLeft);
		glVertex3fv(E);
		glTexCoord2fv(bottomRight);
		glVertex3fv(F);
		glTexCoord2fv(topRight);
		glVertex3fv(B);
		glTexCoord2fv(topLeft);
		glVertex3fv(A);
	glEnd();

	// back
	glBegin(GL_QUADS);
		glNormal3f( 0.0, 0.0, -1.0);
		glTexCoord2fv(bottomLeft);
		glVertex3fv(G);
		glTexCoord2fv(bottomRight);
		glVertex3fv(H);
		glTexCoord2fv(topRight);
		glVertex3fv(D);
		glTexCoord2fv(topLeft);
		glVertex3fv(C);
	glEnd();

	// left
	glBegin(GL_QUADS);
		glNormal3f( -1.0, 0.0, 0.0);
		glTexCoord2fv(bottomLeft);
		glVertex3fv(H);
		glTexCoord2fv(bottomRight);
		glVertex3fv(E);
		glTexCoord2fv(topRight);
		glVertex3fv(A);
		glTexCoord2fv(topLeft);
		glVertex3fv(D);
	glEnd();

	// right
	glBegin(GL_QUADS);
		glNormal3f( 1.0, 0.0, 0.0);
		glTexCoord2fv(bottomLeft);
		glVertex3fv(F);
		glTexCoord2fv(bottomRight);
		glVertex3fv(G);
		glTexCoord2fv(topRight);
		glVertex3fv(C);
		glTexCoord2fv(topLeft);
		glVertex3fv(B);
	glEnd();

}

DefaultCube::~DefaultCube(void) {
}